package com.codejam.pagehelper.starter.controller;

import com.codejam.pagehelper.starter.controller.dto.req.Test1Req;
import com.codejam.pagehelper.starter.dal.dataobject.User;
import com.codejam.pagehelper.starter.service.interfaces.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.UUID;

@RequestMapping("/test")
@RestController
public class TestController {

    @Autowired
    private IUserService userService;

    @PostMapping("/test1")
    public String test1(@Valid @RequestBody Test1Req request) {

        return UUID.randomUUID().toString();
    }


    @PostMapping("/test2")
    public String test2(@Validated @RequestBody Test1Req request) {

        List<User> user = userService.getUser();

        String s = user.toString();

        return UUID.randomUUID().toString() + s;
    }
}
